package com.woniuxy.controller;

import com.woniuxy.entity.RbacMenu;
import com.woniuxy.entity.RbacPerm;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.PermService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class PermController {
    @Autowired(required = false)
    PermService permService;

    @GetMapping("/findPerm/{id}")
    public ResponseEntity<RbacPerm> findPermById(@PathVariable int id){
        RbacPerm rbacPerm = permService.findPermById(id);
        return new ResponseEntity<RbacPerm>(200,"查询成功",rbacPerm);
    }
    @PostMapping("/permadd")
    public ResponseEntity add(@RequestBody RbacPerm rbacPerm){
        int i = permService.add(rbacPerm);
        return new ResponseEntity(200,"添加成功",i);
    }
    @DeleteMapping("/permDelete/{id}")
    public ResponseEntity permDelete(@PathVariable int id){
        int i = permService.permDelete(id);
        return new ResponseEntity(200,"删除成功",i);
    }
    @PutMapping("updatePerm")
    public ResponseEntity updatePerm(@RequestBody RbacPerm rbacPerm){
        int i = permService.updatePerm(rbacPerm);
        return new ResponseEntity(200,"修改成功",i);
    }
}
